﻿<%@ WebHandler Language="C#" Class="CollectionDelete" %>

using System;
using System.Web;
using Newtonsoft.Json;
using OTS.Common;
using OTS.Model;
using OTS.BLL;

public class CollectionDelete : IHttpHandler,System.Web.SessionState.IReadOnlySessionState 
{
    
    public void ProcessRequest (HttpContext context) {
        PageSuccess page = new PageSuccess();
        string _id = context.Request["favID"];
        if (context.Session["custom"]==null || null==_id || "".Equals(_id) || !OTS.Common.Help.IsNumber(_id))
        {
            page.success = false;
            page.msg = "非法操作！";
        }
        else
        {
            int id = Int32.Parse(_id);
            custom cus = new custom();
            cus=(custom)context.Session["custom"];
            FavoriteBLL favBLL = new FavoriteBLL();
            if (favBLL.Detele(id,cus.cusID))
            {
                page.success = true;
                page.msg = id.ToString();
            }
            else
            {
                page.success = false;
                page.msg = "删除失败！";
            }
        }

        context.Response.ContentType = "application/x-json";
        context.Response.Charset = "utf-8";
        context.Response.Write(JavaScriptConvert.SerializeObject(page));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}